package com.xctech.yace.swing.tab;

import com.xctech.yace.VersionRegister;
import com.xctech.yace.main.YaceSendFromDB;
import com.xctech.yace.service.FileService;
import com.xctech.yace.swing.ConfigValue;
import com.xctech.yace.swing.component.ComboboxToolTipRenderer;
import com.xctech.yace.swing.component.LargeComboBoxUI;
import com.xctech.yace.swing.subTab.MonitorSwing;
import com.xctech.yace.util.ReadFiledXML;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;

import static com.xctech.yace.swing.ConfigValue.*;
import static com.xctech.yace.swing.FatherSwing.productPropties;
import static com.xctech.yace.swing.InitFileConfig.topicMap;
import static javax.swing.JOptionPane.*;

public class VersionTabSwing {

    public static String title = "版本升级及操作说明";
    public static String subTitleLeft = "                             版本说明 \n\n";
    public static String subTitleRight = "                                                   操作说明文档 \n\n";

    public static String fileName = "update";

    public static JSplitPane genVersionSplitPanel() {
        //发送画板
        JPanel version = new JPanel();
        //监控画板
        JPanel explain = new JPanel();

        JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, version, explain);
        splitPane.setDividerLocation(1100);

        placeComponentsVersionLeft(explain);
        placeComponentsExplainRight(version);
        return splitPane;
    }

    public static void placeComponentsVersionLeft(JComponent panel){
        /* 布局部分我们这边不多做介绍
         * 这边设置布局为 null
         */
        panel.setLayout(null);

        Vector versionVector = new Vector();
        versionVector.add(subTitleLeft);
        Vector<String> versionInfos = VersionRegister.getVersionInfos(40);
        versionVector.addAll(versionInfos);
        JList versionList = new JList(versionVector);
        JScrollPane scrollPane = new JScrollPane(versionList);
        scrollPane.setBounds(15,15,650,900);
        versionList.setFont(new Font("幼圆",Font.BOLD,18));
        scrollPane.setVerticalScrollBarPolicy(
                JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
        panel.add(scrollPane);
    }

    public static void placeComponentsExplainRight(JComponent panel){
        /* 布局部分我们这边不多做介绍
         * 这边设置布局为 null
         */
        panel.setLayout(null);

        JTextArea area = new JTextArea();
        area.append(subTitleRight);
        area.setEditable(false);
        Map<String, String> ymls = ReadFiledXML.readYmlFile("conf");
        String updateInfo = ymls.get(fileName);
        area.append(updateInfo);

        JScrollPane explainPane = new JScrollPane(area);
        explainPane.setBounds(15,15,1057,900);
        area.setFont(new Font("楷体",Font.PLAIN,18));
        explainPane.setVerticalScrollBarPolicy(
                JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
        panel.add(explainPane);

    }

}
